package org.dioib.practice.common.exception;

import lombok.Getter;

@Getter
public class ResourceNotFoundException extends RuntimeException {
    private final String resourceName;
    private final String identifier;
    private final Object identifierValue;

    public ResourceNotFoundException(String resourceName, String identifier, Object identifierValue) {
        super(String.format("%s not found with %s: '%s'", resourceName, identifier, identifierValue));
        this.resourceName = resourceName;
        this.identifier = identifier;
        this.identifierValue = identifierValue;
    }

    public ResourceNotFoundException(String resourceName, String identifier, Object identifierValue, Throwable cause) {
        super(String.format("%s not found with %s: '%s'", resourceName, identifier, identifierValue), cause);
        this.resourceName = resourceName;
        this.identifier = identifier;
        this.identifierValue = identifierValue;
    }

    public String getResourceId() {
        return identifier;
    }
}